// !#1
import { HashRouter, Route, Link } from 'react-router-dom'
import FindMusic from './pages/FindMusic'
import MyMusic from './pages/MyMusic'
import MyFollow from './pages/MyFollow'

export default function App() {
  // !#2 HashRouter 包裹整个应用
  return (
    <HashRouter>
      <nav className='navbar navbar-expand-lg navbar-light bg-light'>
        <div className='container'>
          <a className='navbar-brand' href='##'>
            网易云
          </a>
          <button
            className='navbar-toggler'
            type='button'
            data-bs-toggle='collapse'
            data-bs-target='#navbarSupportedContent'
            aria-controls='navbarSupportedContent'
            aria-expanded='false'
            aria-label='Toggle navigation'
          >
            <span className='navbar-toggler-icon'></span>
          </button>
          <div className='collapse navbar-collapse' id='navbarSupportedContent'>
            <ul className='navbar-nav me-auto mb-2 mb-lg-0'>
              {/* //!#3 指定 a 链接的 hash 地址 */}
              <li className='nav-item'>
                <Link
                  className='nav-link active'
                  aria-current='page'
                  to='/findmusic'
                >
                  发现音乐
                </Link>
              </li>
              <li className='nav-item'>
                <Link className='nav-link' aria-current='page' to='/mymusic'>
                  我的音乐
                </Link>
              </li>
              <li className='nav-item'>
                <Link className='nav-link' aria-current='page' to='/myfollow'>
                  关注
                </Link>
              </li>
            </ul>
          </div>
        </div>
      </nav>
      <div className='container mt-3'>
        <div className='card'>
          <div className='card-body'>
            {/* //!#4 当 Link 组件 to 属性 和 Route 组件 path 属性匹配的时候会使用 component 组件 */}
            <Route path='/findmusic' component={FindMusic} />
            <Route path='/mymusic' component={MyMusic} />
            <Route path='/myfollow' component={MyFollow} />
          </div>
        </div>
      </div>
    </HashRouter>
  )
}
